package ie.lawlor.amvc.example.explorer.filemenu;

import ie.lawlor.amvc.swing.JMenuView;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JMenuItem;



/**
 * @author blawlor
 * TODO Add menu items and their (shared) actions.
 * TODO This is a JavaBean. Add properties that can allow the 
 * Items to be added, as well as the Controller. May need to 
 * make other items protected rather than public so that they 
 * don't appear in the JavaBean's interface.
 */
public class FileMenuView extends JMenuView {

	public Action FILE_EXIT_ACTION = new AbstractAction("Exit") {
		public void actionPerformed(ActionEvent evt) {
			fire(getController().getEvent("fileMenuExitEvent"));
		}};
	public Action FILE_OPEN_ACTION = new AbstractAction("Open") {
		public void actionPerformed(ActionEvent evt) {
			//TODO Get events from Spring container perhaps?
			fire(getController().getEvent("fileMenuOpenEvent"));
		}};
	
    /* (non-Javadoc)
     * @see com.spokesoft.hmvc.swing.JMenuView#getMenuName()
     */
    protected String getMenuName() {
    	return "File";
   }

    /**
     * 
     */
    public FileMenuView(String name) {
        super(name);
        add(new JMenuItem(FILE_OPEN_ACTION));
        add(new JMenuItem(FILE_EXIT_ACTION));
    }

}
